#!/usr/bin/env bash
# SPDX-License-Identifier: BSD-3-Clause
# Copyright 2016-2018, Intel Corporation
#
#
# rpmemd_config/TEST0 -- test for rpmemd default config and cl arguments
#

. ../unittest/unittest.sh

require_test_type medium
require_build_type debug
require_fs_type any

setup

RPMEMD=./rpmemd_config$EXESUFFIX

OUT=stdout${UNITTEST_NUM}.log
LOG=out${UNITTEST_NUM}.log
LOG_TEMP=out${UNITTEST_NUM}_temp.log
rm -f $OUT $LOG $LOG_TEMP

EMPTY_CONFIG=in${UNITTEST_NUM}.conf
INVALID_CONFIG=$DIR/invalid.conf

# use empty config to prevent loading config file from default location
# which may have nondefault configuration
expect_normal_exit $RPMEMD -c $EMPTY_CONFIG 1>> $OUT 2>&1
cat $LOG >> $LOG_TEMP

expect_normal_exit $RPMEMD -V 1>> $OUT 2>&1
cat $LOG >> $LOG_TEMP

expect_normal_exit $RPMEMD --version 1>> $OUT 2>&1
cat $LOG >> $LOG_TEMP

expect_normal_exit $RPMEMD -h 1>> $OUT 2>&1
cat $LOG >> $LOG_TEMP

expect_normal_exit $RPMEMD --help 1>> $OUT 2>&1
cat $LOG >> $LOG_TEMP

expect_normal_exit $RPMEMD -c $EMPTY_CONFIG 1>> $OUT 2>&1
cat $LOG >> $LOG_TEMP

expect_normal_exit $RPMEMD --config $EMPTY_CONFIG 1>> $OUT 2>&1
cat $LOG >> $LOG_TEMP

expect_normal_exit $RPMEMD -c $INVALID_CONFIG 1>> $OUT 2>&1
cat $LOG >> $LOG_TEMP

expect_normal_exit $RPMEMD --config $INVALID_CONFIG 1>> $OUT 2>&1
cat $LOG >> $LOG_TEMP

$GREP -v rpmemd_config $LOG_TEMP > $LOG

check

pass
